﻿using System;
using System.Text;
using Microsoft.Win32;

namespace Boxie
{
    class BoxieRegLib
    {
        public static bool GetSettingBool(string setting, bool defaultValue)
        {
            RegistryKey regKey = Registry.CurrentUser;
            regKey = regKey.CreateSubKey("Software\\Boxie");

            string tmp = regKey.GetValue(setting, defaultValue.ToString()).ToString();
            if (tmp == "True")
                return true;
            else if (tmp == "False")
                return false;
            else
                return defaultValue;
        }

        public static void SaveSettingBool(string setting, bool val)
        {
            RegistryKey regKey = Registry.CurrentUser;
            regKey = regKey.CreateSubKey("Software\\Boxie");

            regKey.SetValue(setting, val.ToString());
        }

        public static string GetSettingString(string setting, string defaultValue)
        {
            RegistryKey regKey = Registry.CurrentUser;
            regKey = regKey.CreateSubKey("Software\\Boxie");

            return regKey.GetValue(setting, defaultValue).ToString();
        }

        public static void SaveSettingString(string setting, string val)
        {
            RegistryKey regKey = Registry.CurrentUser;
            regKey = regKey.CreateSubKey("Software\\Boxie");

            regKey.SetValue(setting, val);
        }

        public static int GetSettingInt(string setting, int defaultValue)
        {
            string tmp = GetSettingString(setting, defaultValue.ToString());
            return Convert.ToInt32(tmp);
        }
    }
}
